#!/usr/bin/node

const fs = require('fs'),
      src = process.argv[2],
      dst = process.argv[3];

try{
  //Copy file content
  let srcstream = fs.createReadStream(src);
  let dststream = fs.createWriteStream(dst);

  srcstream.pipe(dststream);

  dststream.on('close',()=>{
  //Copy file permissions
    fs.chmodSync(dst, fs.statSync(src).mode);
  })

}catch(e){
  console.error(e.message);
  process.exit(1);
}
